package utils

const (
	RECODE_OK                  = "0"
	RECODE_UNKNOWERR           = "999"
	RECODE_USER_ALREADY_EXISTS = "100"
	RECODE_USER_NOT_EXISTS     = "101"
	RECODE_PASSWORD_ERR        = "102"
	RECODE_BALANCE_NOT_ENOUGH  = "103"
	RECODE_TASK_NOT_EXISTS     = "104"
	RECODE_TASK_CANNOT_TAKE    = "105"
	RECODE_TASK_CANNOT_COMMIT  = "106"
	RECODE_TASK_CANNOT_CONFRIM = "107"
	RECODE_CHAINCODE_PUT_ERR   = "108"
	RECODE_CHAINCODE_GET_ERR   = "109"
	RECODE_CHAINCODE_DEL_ERR   = "110"
	RECODE_JSON_ERR            = "111"
	RECODE_PARAMERR            = "112"
	RECODE_CALL_CC_ERR         = "113"
	RECODE_SESSION_ERR         = "114"
)

var recodeText = map[string]string{
	RECODE_OK:                  "成功",
	RECODE_UNKNOWERR:           "未知错误",
	RECODE_USER_ALREADY_EXISTS: "用户已经存在",
	RECODE_USER_NOT_EXISTS:     "用户不存在",
	RECODE_PASSWORD_ERR:        "密码错误",
	RECODE_BALANCE_NOT_ENOUGH:  "余额不足",
	RECODE_TASK_NOT_EXISTS:     "任务不存在",
	RECODE_TASK_CANNOT_TAKE:    "任务不可接受",
	RECODE_TASK_CANNOT_COMMIT:  "任务不可提交",
	RECODE_TASK_CANNOT_CONFRIM: "任务不可确认",
	RECODE_CHAINCODE_PUT_ERR:   "链码提交数据失败",
	RECODE_CHAINCODE_GET_ERR:   "链码读取数据失败",
	RECODE_CHAINCODE_DEL_ERR:   "链码删除数据失败",
	RECODE_JSON_ERR:            "json转换失败",
	RECODE_PARAMERR:            "参数错误",
	RECODE_CALL_CC_ERR:         "链码调用失败",
	RECODE_SESSION_ERR:         "SESSION处理错误",
}

const (
	STATUS_PUBLISH = iota
	STATUS_TAKE
	STATUS_COMMIT
	STATUS_CONFRIM
)

func RecodeText(code string) string {
	str, ok := recodeText[code]
	if ok {
		return str
	}
	return recodeText[RECODE_UNKNOWERR]
}
